package chkui.springcore.example.javabase.conversion;

import java.util.HashSet;
import java.util.Set;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.core.convert.converter.Converter;

import chkui.springcore.example.javabase.conversion.support.PC2StringConverter;
import chkui.springcore.example.javabase.conversion.support.String2PcConverter;;

@Configurable
public class ConversionConfig {
	
	@Bean
	public ConversionServiceFactoryBean ConversionServiceFactoryBean() {
		ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
		@SuppressWarnings("rawtypes")
		Set<Converter> converters = new HashSet<>();
		// 添加自定义转换器
		converters.add(new String2PcConverter());
		converters.add(new PC2StringConverter());
		factoryBean.setConverters(converters);
		return factoryBean;
	}
}
